package acm.广东工业大学新生赛;

import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        while (n-- > 0) {
            int x=sc.nextInt();
            int y=sc.nextInt();
            int z=sc.nextInt();
            int day = (x + y + z) % 7;
            System.out.println(day==0?7:day);
        }
    }
}
